/*
 * Copyright 2015, 2020 StreamEx contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package lambdasinaction.appc;

import com.alibaba.fastjson.JSON;
import one.util.streamex.StreamEx;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class ApptecTest {

    public static void main(String[] args) {
        Stream<Integer> integerStream = Stream.of(1, 2, 3);

        StreamForker.Results results = new StreamForker<>(integerStream)
                .fork(
                        "name", a -> a.map(String::valueOf).collect(Collectors.toList())
                )
                .fork(
                        "age", a -> a.map(x -> x + 10).collect(Collectors.toList())
                ).getResults();

        List<String> name = results.get("name");
        List<Integer> age = results.get("age");
        System.out.println(JSON.toJSONString(name));
        System.out.println(JSON.toJSONString(age));
    }

}
